from selenium import webdriver
from time import sleep
from selenium.webdriver.common.keys import Keys


# 后面是你的浏览器驱动位置，记得前面加r'','r'是防止字符转义的
driver = webdriver.Chrome(r'C:\Users\Administrator\AppData\Local\Programs\Python\Python38\chromedriver.exe')
driver.maximize_window()
# 用get打开百度页面
driver.get("https://www.baidu.com")
sleep(2)
bdinput = driver.find_element_by_id('kw').send_keys('青岛网站制作公司')
sleep(2)
driver.find_element_by_id("su").send_keys(Keys.ENTER)
sleep(5)
page = 1
for i in driver.find_elements_by_class_name("pc"):
    if int(i.text) == int(page + 1):
        i.click()
        # driver.switch_to.window(driver.window_handles[0])
